import { defineStore } from "pinia";
import homeApi, {
  type VideoListModel,
  type ContentModel,
  type VideoPlayModel
} from "@/api/mockHome";

const useHomeStore = defineStore({
  id: "home",
  state: () => ({
    videoList: [] as ContentModel[],
    videoPlay: {} as VideoPlayModel
  }),
  actions: {
    async getHomeRecommend() {
      try {
        const result = await homeApi.getVideoList();
        this.videoList = result.content;

        console.log(this.videoList);
      } catch (error) {
        console.log(error);
      }
    },
    async getProductionSynthesize(bili:string) {
      try {
        const result = await homeApi.getProductionSynthesize(bili);
        this.videoList = result.content;

        console.log(this.videoList);
      } catch (error) {
        console.log(error);
      }
    },
    async getCourseSynthesize() {
      try {
        const result = await homeApi.getCourseSynthesize();
        this.videoList = result.content;

        console.log(this.videoList);
      } catch (error) {
        console.log(error);
      }
    },
    async getDynamic() {
      try {
        const result = await homeApi.getCourseSynthesize();
        this.videoList = result.content;

        console.log(this.videoList);
      } catch (error) {
        console.log(error);
      }
    },
    async getVideoPlay(){
      try {
        const result = await homeApi.getVideoPlay();
        this.videoPlay = result
      } catch (error) {
        console.log(error)
      }
    }
  },
  getters: {},
});

export default useHomeStore;
